<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="noticeName"/>
                        </li>

                        <li class="select-time">
                            <label>发布时间： </label>
                            <input type="text" class="date-input" id="startReleaseTime" placeholder="开始"
                                   name="params[beginReleaseTime]"/>
                            <span>-</span>
                            <input type="text" class="date-input" id="endReleaseTime" placeholder="结束"
                                   name="params[endReleaseTime]"/>
                        </li>

                        <li>
                            作者：<input type="text" name="noticeAuthor"/>
                        </li>
                        <li>
                            新闻类型：<select name="noticeType" th:with="type=${@dict.getType('wdy_notice_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            中英文 0中文1英文：<input type="text" name="zyType"/>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="date-input" id="startCreateTime" placeholder="开始"
                                   name="params[beginCreateTime]"/>
                            <span>-</span>
                            <input type="text" class="date-input" id="endCreateTime" placeholder="结束"
                                   name="params[endCreateTime]"/>
                        </li>

                        <li>
                            备注信息：<input type="text" name="remark"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="system:wdyNotice:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.editFull()"
               shiro:hasPermission="system:wdyNotice:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:wdyNotice:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:wdyNotice:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:wdyNotice:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:wdyNotice:remove')}]];
    var noticeType = [[${@dict.getType('wdy_notice_type')}]];
    var prefix = ctx + "system/wdyNotice";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "新闻公告",
            showExport: false,
            sortName: "createTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'noticeName',
                    title: '标题',
                    sortable: true
                },
                {
                    field: 'noticeImage',
                    title: '活动图',
                    formatter: function (value, row, index) {
                        return showImage(row);
                    }
                },
                {
                    field: 'releaseTime',
                    title: '发布时间',
                    sortable: true
                },
                {
                    field: 'noticeAuthor',
                    title: '作者',
                    sortable: true
                },

                {
                    field: 'noticeType',
                    title: '新闻类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(noticeType, value);
                    }
                },
                {
                    field: 'delFlag',
                    title: '删除标志（0代表存在 1代表删除）',
                    sortable: true
                },

                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },

                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: '备注信息',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function showImage(row) {
        return '<img src="' + row.noticeImage + '" width="100px" height="100px">'
    }

</script>
</body>
</html>